%%% Copyright 2010 Google Inc.
%%%
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
%%% You may obtain a copy of the License at
%%%
%%%     http://www.apache.org/licenses/LICENSE-2.0
%%%
%%% Unless required by applicable law or agreed to in writing, software
%%% distributed under the License is distributed on an "AS IS" BASIS,
%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%%% See the License for the specific language governing permissions and
%%% limitations under the License.

%%% Author <jacoby@google.com> Jacoby Thwaites [http://sites/madcloud]
%%%
%%% Header file for the  graph: and graph_tests: modules.

%% An agenda item is generated for each output set of an operation. The type
%% can be vertex (for N and IRR ops) or edge (for RR ops). In the case of
%% an edge, the input vertex is specified. A separate agenda item is created
%% for each output set in any one operation.
-define(VERTEX, vertex).
-define(EDGE, edge).

-define(AGENDA, graph_agenda).
-record(?AGENDA, {key = now(),
                  type = ?UNDEFINED :: ?VERTEX | ?EDGE,
                  opRef = ?UNDEFINED,
                  inputVertex = ?UNDEFINED,
                  outputName = ?UNDEFINED,
                  vertexSet = ?UNDEFINED}).

%% Agenda item returned when empty.
-define(AGENDA_EMPTY, agenda_empty).

%% Null accumulator for dict:fold.
-define(NULL_ACC, null_acc).

%% A used item is a fieldset already present in the graph.
-define(USED, graph_used).
-record(?USED, {vertexSet = ?UNDEFINED,
                vertex = ?UNDEFINED}).

%% @type vertex_label() = #vertex_label{}.
%% Each vertex is labelled with one vertex_label record. Fields are:
%% <ul>
%% <li>`vertexSet' is the set of field references in this vertex.</li>
%% <li>`satisfies' is the the list of IRR and OO op `id' that can consume
%%     the fields present on this vertex.</li>
%% <li>`producedBy' is the list of N and IRR op `{id, outputName}' that produce
%%     the fields on this vertex.</li>
%% </ul>
-define(VERTEX_LABEL, vertex_label).
-record(?VERTEX_LABEL, {vertexSet = ?UNDEFINED :: set(),
                        satisfies = []         :: list(),
                        producedBy = []        :: list()}).

%% Each edge is labelled with the id of the RR op that generated the edge.
%% If that generator has multiple outputs then the field is set to true,
%% otherwise false.
-define(EDGE_LABEL, edge_label).
-record(?EDGE_LABEL, {generator = ?UNDEFINED    :: ref(),
                      outputName = ?UNDEFINED   :: string()}).
